package com.cgy.utils.spider.setting;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import us.codecraft.webmagic.downloader.Downloader;

/**
 * 设置
 * @author CHTK
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Accessors(fluent = true)
public class Setting {
    private int retryTime = 3;
    private int sleepTime = 10000;
    private int timeout = 10000;
    private String charset = "UTF-8";
    private int cycleRetryTime = 3;
    private boolean isDeep = true;
    private boolean async = false;
    private String download;
    private boolean console = true;
    private Downloader downloader;
    private boolean fullPage = true;

    public static Setting build() {
        return new Setting();
    }

    public Setting downloader(Downloader downloader) {
        System.setProperty("selenuim_config", "F:/config.ini");
        this.downloader = downloader;
        return this;
    }

    public Setting downloader(Downloader downloader, String config) {
        System.setProperty("selenuim_config", config);
        this.downloader = downloader;
        return this;
    }
}
